<template>
  <ul class="menu-container">
    <li>
      <RouterLink
        :exact="item.exact"
        v-for="item in items"
        :key="item.name"
        :to="{ name: item.name }"
        active-class="selected"
        exact-active-class=""
      >
        <Icon :type="item.icon" />
        <span>{{ item.title }}</span>
      </RouterLink>
    </li>
  </ul>
</template>

<script>
import Icon from "@/components/Icon";
export default {
  components: {
    Icon,
  },
  data() {
    return {
      items: [
        {
          name: "Home",
          title: "首页",
          icon: "home",
          exact: true, //精确匹配 需要 你的数据链接地址 跟 浏览器的地址完全一直时 内样式 才会生效
        },
        {
          name: "Blog",
          title: "文章",
          icon: "blog",
          exact: false, //用来处理当前路径以name 开头的 菜单栏就选中
        },
        {
          name: "About",
          title: "关于我",
          icon: "about",
          exact: false, //用来处理当前路径以name 开头的 菜单栏就选中
        },
        {
          name: "Project",
          title: "项目&效果",
          icon: "code",
          exact: false, //用来处理当前路径以/blod 开头的 菜单栏就选中
        },
        {
          name: "Message",
          title: "留言板",
          icon: "chat",
          exact: false, //用来处理当前路径以/blod 开头的 菜单栏就选中
        },
      ],
    };
  },
};
</script>

<style scoped lang="less">
@import "~@/styles/var.less";
.menu-container {
  color: @gray;
  margin: 24px 0;
  a {
    &.selected {
      background: darken(@words, 3%);
    }
    padding: 0 50px;
    display: block;
    display: flex;
    align-items: center;
    height: 45px;
    .iconfont {
      width: 24px;
    }
    &:hover {
      color: #fff;
    }
  }
}
</style>